<div class="card card-primary">
    <div class="card-body">
        <div class="filter-panel d-none">
			<form action="" method="get" class="frm-filter">
				<div class="row">
					<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
						<div class="form-group row">
							<label class="col-lg-2 col-md-2 col-sm-3 col-xs-6 mb-0 pt-2 text-right">{:lang("Title")}</label>
							<div class="col-lg-10 col-md-10 col-sm-9 col-xs-6">
								<input type="text" class="form-control" name="name" placeholder="{:lang('Title')}" data-op="like %...%">
							</div>
						</div>
					</div>
					<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
						<div class="form-group text-start">
							<input type="reset" class="btn btn-default" value="{:lang('Reset')}">
							<input type="submit" class="btn btn-primary ml-2" value="{:lang('Search')}">
						</div>
					</div>
				</div>
			</form>
        </div>
		<div id="toolbar" class="toolbar">
		    {:build_toolbar('refresh')}
            <!--<button type="button" class="btn btn-secondary btn-refresh" data-toggle="tooltip" data-placement="top" title="" data-original-title="{:lang('Reload page')}"><i class="fas fa-redo-alt"></i></button>&nbsp;-->
            {if (has_rule('add'))}
			<a href="javascript:cmsOpen('{:url('/friendlinks/add',['popup'=>1])}','{:lang("Add")}')" class="btn btn-primary btn-add"><i class="fas fa-plus"></i>
                {:lang('Add')}</a>&nbsp;
            {/if}
            {if (has_rule('del'))}
            <button type="button" class="btn btn-disabled btn-danger disabled btn-del" data-url="{:url('/friendlinks/del')}"><i class="fas fa-trash-alt"></i>
                {:lang('Delete')}</button>
            {/if}
            {if (has_rule('batches'))}
            <div class="dropdown ml-1 btn-toggle">
                <a class="btn btn-secondary dropdown-toggle btn-disabled disabled" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <i class="fas fa-"></i> {:lang('Setting')}
                </a>
                <div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
                    <a class="dropdown-item status" href="#" data-params="status=normal">{:lang('Set to enable')}</a>
                    <a class="dropdown-item status" href="#" data-params="status=hidden">{:lang('Set to disabled')}</a>
                </div>
            </div>
            {/if}
        </div>
        <table id="table"
               data-del="{if has_rule('del')}{:url('/Friendlinks/del')}{/if}"
               data-batches="{if has_rule('batches')}{:url('/Friendlinks/batches')}{/if}"
        ></table>
    </div>
</div>

{block:script}
<script>
    require(['admin','table'], function (undefined,cmsTable) {
        $(function () {
            var table = cmsTable.init({
                url: "{:url('/Friendlinks/index')}",
                search: false,
                escape: false,
                sortName:'weigh,id',
                customFilter: true,
                columns: [{
                    field: 'state',
                    checkbox: true,
                },{
                    field: 'weigh',
                    title: '{:lang("Weigh")}',
                    formatter:cmsTable.formatter.txtEditBtn,
                    events:cmsTable.events.txtEditBtn
                },{
                    field: 'SN',
                    title: '{:lang("Serial number")}',
                    formatter: cmsTable.formatter.SN
                },{
                    field: 'name',
                    title: '{:lang("Title")}',
                    align: 'left',
                },{
                    field: 'url',
                    title: '{:lang("Url")}',
                    align: 'left',
                },{
                    field: 'new_window',
                    title: '{:lang("New window")}',
                    formatter: cmsTable.formatter.switchBtn,
                    events: cmsTable.events.switchBtn
				},{
                    field: 'status',
                    title: '{:lang("Status")}',
                    formatter: cmsTable.formatter.switchBtn,
                    events: cmsTable.events.switchBtn
                },{
                    field: 'operate',
                    title: '{:lang("Operate")}',
                    formatter: function (value, row, index) {
                        let edit_url = Util.setUrlParams({ url:'{:url("/Friendlinks/edit")}', query:{popup:1,id:row['id']} });
                        let html = '';

                        /* {if has_rule('edit')} */
						html = '<a href="#!" onclick="hkcms.api.open(\''+edit_url+'\',\'{:lang("edit")}\')" class="btn btn-primary btn-xs text-white"><i class="fas fa-pen"></i></a>&nbsp';
                        /* {/if} */

                        return html+cmsTable.formatter.operate.call(this, value, row, index)
                    },
                    events: cmsTable.events.operate
                }]
			});
        })
    })
</script>
{/block:script}